//
//  DXMainTabBarController.m
//  OC-DXWeibo
//
//  Created by xiongdexi on 16/4/7.
//  Copyright © 2016年 DXSmile. All rights reserved.
//

#import "DXMainTabBarController.h"
#import "DXHomeTableViewController.h"
#import "DXMessageTableViewController.h"
#import "DXDiscoverTableViewController.h"
#import "DXProfileTableViewController.h"
#import "DXComposedViewController.h"
#import "UIButton+DXExtension.h"

@interface DXMainTabBarController ()



/* composedButton */
@property (nonatomic, strong) UIButton *composedButton;

@end

@implementation DXMainTabBarController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    // 添加子控制器
    [self addChildViewControllers];
    
    // 添加中间composedButton按钮
    [self setupComposedButton];
    
}
/// 添加子控制器
- (void)addChildViewControllers {

    self.tabBar.tintColor = [UIColor orangeColor];
    
    DXHomeTableViewController *home = [[DXHomeTableViewController alloc] init];
    [self addOneChildViewController:home title:@"首页" imageName:@"tabbar_home"];
    
    DXMessageTableViewController *message = [[DXMessageTableViewController alloc] init];
    [self addOneChildViewController:message title:@"消息" imageName:@"tabbar_message_center"];
    
    DXComposedViewController *pushVC = [[DXComposedViewController alloc] init];
    [self addOneChildViewController:pushVC title:nil imageName:nil];
    
    DXDiscoverTableViewController *discover = [[DXDiscoverTableViewController alloc] init];
    [self addOneChildViewController:discover title:@"发现" imageName:@"tabbar_discover"];
    
    DXProfileTableViewController *profile = [[DXProfileTableViewController alloc] init];
    [self addOneChildViewController:profile title:@"我" imageName:@"tabbar_profile"];

}

/// 添加一个控制器
- (void)addOneChildViewController:(UIViewController *)VC title:(NSString *)title imageName:(NSString *)imageName {
    VC.title = title;
    VC.tabBarItem.image = [UIImage imageNamed:imageName];
    UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:VC];
    [self addChildViewController:nav];
    
}

/// 添加composedButton中间按钮
- (void)setupComposedButton {

    self.composedButton = [[UIButton alloc] initWithImageName:@"tabbar_compose_icon_add" backImageName:@"tabbar_compose_button"];
//    self.composedButton.sizeToFit;
    
}



@end
